import { NextResponse } from 'next/server';
import pool from '@/lib/db';

// 获取所有公开的提示词
export async function GET() {
  try {
    // 只获取公开的提示词，并按创建时间倒序排序
    const result = await pool.query(
      'SELECT * FROM prompts WHERE is_public = true ORDER BY created_at DESC'
    );
    
    return NextResponse.json(result.rows);
  } catch (error) {
    console.error('Database error:', error);
    return NextResponse.json({ error: error.message }, { status: 500 });
  }
}